#pragma once

#include <cstdint>
#include <ctime>
#include <deque>
#include <vector>

typedef struct PrimitiveData {
    int64_t i_part;
    uint16_t d_part;
    time_t update_time;
    uint16_t milliseconds;
} PrimitiveData;

class PrimitiveDataManager
{
public:
    ~PrimitiveDataManager() = default;

    static PrimitiveDataManager& get_instance()
    {
        static PrimitiveDataManager instance;
        return instance;
    }

    PrimitiveData& get_primitive_data(uint16_t);
    void set_primitive_data(uint16_t, const PrimitiveData&);
    void set_primitive_data(uint16_t, int64_t, uint16_t, time_t, uint16_t);
    uint16_t get_available_position(const std::string&);

private:
    PrimitiveDataManager();
    PrimitiveDataManager(const PrimitiveDataManager&) = delete;
    PrimitiveDataManager& operator=(const PrimitiveDataManager&) = delete;

    static const uint16_t max_variables = 20000;
    PrimitiveData mem_spaces_[max_variables];

    std::deque<uint16_t> available_positions_;
    std::vector<std::string> variable_sns_;
};